TARGET = rotana
DEPEND = $(TARGET).o rot_tsetups.o rot_lv_serial.o rot_servo.o 
DEPEND += rot_tacho.o rot_adc.o rot_ap.o

CC = avr-gcc
CFLAGS = -Wall -Os -mcall-prologues -mmcu=atmega168
OBJ2HEX = avr-objcopy
AVRDUDE = avrdude
DUDEFLAGS = -c avrispmkII -p m168 -P /dev/ttyUSB0 -e -U lfuse:w:0xe6:m

all: upload

upload: $(TARGET).hex
	$(AVRDUDE)  $(DUDEFLAGS) -U flash:w:$<

%.hex: %.obj
	$(OBJ2HEX) -R .eeprom -O ihex $< $@

%.obj: $(DEPEND)
	$(CC) $(CFLAGS) $(DEPEND) -o $@

$(DEPEND):

clean:
	rm -f *.hex *.obj *.o *~ \#*\#
